<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>广告管理</h2>
    </div>

    <div class="cf">

        <a class="btn J_showdialog" href="javascript:;;" data-title="新增广告" data-id="Add" data-width="600" data-uri="{:U('adAdm',array('pid'=>I('get.pid',0)) )}">新 增</a>
        <button class="btn ajax-post confirm" url="{:U('adDel')}" target-form="ids">删 除</button> 
        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <div class="sleft">
                <input type="text" name="title" class="search-input" value="{:I('title')}" placeholder="广告名称">
                <a class="sch-btn" href="javascript:;" id="search" url="__SELF__"><i class="btn-search"></i></a>
            </div>
        </div>
    </div>
 
    <div class="data-table table-striped J_tablelist" data-acturi="{:U('ajax_edit')}">
        <form class="ids">
            <table>
                <thead>
                  <tr>
                       <th class="row-selected">
                            <input class="checkbox check-all" type="checkbox">
                       </th> 
					   <th><span data-tdtype="order_by" data-field="ad_id">广告id</span></th>
					   <th><span data-tdtype="order_by" data-field="pid">广告位置<span></th>
					   <th><span data-tdtype="order_by" data-field="ad_name">广告名称</span></th>
					   <th><span data-tdtype="order_by" data-field="ad_code">广告图片</span></th>	                   
					   <th><span data-tdtype="order_by" data-field="ad_link">广告链接</span></th>
					   <th><span data-tdtype="order_by" data-field="start_time">投放时间</span></th>	
					   <th><span data-tdtype="order_by" data-field="end_time">结束时间</span></th>	
					   <th>新窗口</th>
					   <th>是否显示</th>
					   <th><span data-tdtype="order_by" data-field="orderby">排序</span></th>
					   <th>操作</th>
                    </tr>
                </thead>
                <tbody>
				<notempty name="list">
                 <volist name="list" id="vo">
                    <tr>
                        <td><input class="ids row-selected" type="checkbox" name="id[]" value="{$vo.ad_id}"></td>
                        <td>{$vo.ad_id}</td> 
					    <td>{$plist[$vo[pid]]}</td> 						
                        <td><span data-tdtype="edit"  data-id="{$vo['ad_id']}" data-idfield="ad_id" data-field="position_name" class="tdedit">{$vo.ad_name}</span></td>
                        <td><img src="{$vo.ad_code|get_cover='path'}" data-bimg="{$vo.ad_code|get_cover='path'}" class="J_preview" width="100" height="50"/></td>
                        <td><span data-tdtype="edit"  data-id="{$vo['ad_id']}" data-idfield="ad_id" data-field="ad_link" class="tdedit">{$vo.ad_link}</span></td>
                        <td>{$vo.start_time|xdate='Y-m-d H:i:s',###}</td>
					    <td>{$vo.end_time|xdate='Y-m-d H:i:s',###}</td>

             
						<td>  
                           <img data-tdtype="toggle"  data-id="{$vo.ad_id}" data-idfield="ad_id" data-field="target" data-value="{$vo.target}" src="{$vo.target|status_pic}" /> 
                        </td>     
					    <td>  
                           <img data-tdtype="toggle"  data-id="{$vo.ad_id}" data-idfield="ad_id" data-field="enabled" data-value="{$vo.enabled}" src="{$vo.enabled|status_pic}" /> 
                        </td>  
                       <td><span data-tdtype="edit"  data-id="{$vo['ad_id']}" data-idfield="ad_id" data-field="position_name" class="tdedit">{$vo.ad_name}</span></td>
                        <td>
						    <a class="J_showdialog" href="javascript:;;" data-title="编辑" data-id="Adm" data-width="600" data-uri="{:U('adAdm',array('id'=>$vo[ad_id]))}">编辑</a>
                            <a class="confirm ajax-get" title="删除" href="{:U('adDel?id='.$vo['ad_id'])}">删除</a>
                        </td>
                    </tr>
                </volist>
				<else/>
				<td colspan="10" class="text-center"> aOh! 暂时还没有内容! </td>
				</notempty>
                </tbody>
            </table>
        </form>
        <!-- 分页 -->
        <div class="page">

        </div>
    </div>
</block>

<block name="script">
<script status="text/javascript">
$(function(){
     think.use('ajaxForm','listTable',function(){
        $('.J_tablelist').listTable();
     }); 
});
</script>

    <script type="text/javascript">
        $(function() {
            //搜索功能
            $("#search").click(function() {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function(e) {
                if (e.keyCode === 13) {
                    $("#search").click();
                    return false;
                }
            });
            //导航高亮
            highlight_subnav('{:U('poslist')}');
            //点击排序
        	$('.list_sort').click(function(){
        		var url = $(this).attr('url');
        		var ids = $('.ids:checked');
        		var param = '';
        		if(ids.length > 0){
        			var str = new Array();
        			ids.each(function(){
        				str.push($(this).val());
        			});
        			param = str.join(',');
        		}

        		if(url != undefined && url != ''){
        			window.location.href = url + '/ids/' + param;
        		}
        	});
        });
    </script>
</block>